from django.db import models


# Create your models here.
# 创建模型类
# 电脑类
class ComputerModel(models.Model):
    # 品牌
    brand = models.CharField(max_length=20)
    # 价格
    price = models.FloatField()  # 尽量一次设定完成
    # price = models.FloatField(null=True)
    # price = models.FloatField(default=0)  # 临时设定的?
    # 生产日期
    producetime = models.DateField()
    # 输出对象名,输出内容值
    def __str__(self):
        # 返回值
        return "品牌名称:"+str(self.brand)

# class FactoryModel(object):  # 未继承Model
class FactoryModel(models.Model):
    # 名称
    name = models.CharField(max_length=20)
    # 是否上市
    islisted = models.BooleanField()
    # 简介
    content = models.CharField(max_length=400)
    # 关联主键
    computerid = models.ForeignKey("ComputerModel")
    #
    def __str__(self):
        return "工厂名称:"+str(self.name)
